package com.sgb.kjwl.view.ui.adapter.transport;

import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sgb.kjwl.R;

import java.util.List;

/**
 * @author: 杨畔
 * @date: 3/9/21 10:25 AM
 * @Description: 凭证图片适配器
 */
public class CertificateImageAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    private final RequestOptions options;

    public CertificateImageAdapter(@Nullable List<String> data) {
        super(R.layout.item_certificate_image, data);
        options = new RequestOptions()
                .placeholder(R.drawable.null_img_list)//图片加载出来前，显示的图片
                .error(R.drawable.null_img_list);//图片加载失败后，显示的图片
    }

    public CertificateImageAdapter(@Nullable List<String> data, int px) {
        super(R.layout.item_certificate_image, data);
        RoundedCorners roundedCorners = new RoundedCorners(px);
        options = new RequestOptions()
                .bitmapTransform(roundedCorners)
                .placeholder(R.drawable.null_img_list)//图片加载出来前，显示的图片
                .error(R.drawable.null_img_list);//图片加载失败后，显示的图片
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        Glide.with(mContext).load(item).apply(options).into((ImageView) helper.getView(R.id.iv_certificate_image));
    }
}
